package com.example.springboottest.example.thread;

public class ThreadTest {

    public static void main(String[] args) {
//        testSync();
        testLock();
    }

    public static void testSync() {
        TestSyncService testSyncService = new TestSyncService();
//        TestServiceImpl serviceImpl2 = new TestServiceImpl();
        ThreadSync run1 = new ThreadSync(testSyncService);
        ThreadSync run2 = new ThreadSync(testSyncService);
//        ThreadTest2 run2 = new ThreadTest2(serviceImpl2);
        for (int i = 0; i < 5; i++) {
            Thread t1 = new Thread(run1);
            Thread t2 = new Thread(run2);
            t1.start();
            t2.start();
        }
    }

    public static void testLock() {
        TestLockService testLockService = new TestLockService();
        ThreadLock run1 = new ThreadLock(testLockService);
        ThreadLock2 run2 = new ThreadLock2(testLockService);
        for (int i = 0; i < 5; i++) {
            Thread t1 = new Thread(run1);
            Thread t2 = new Thread(run2);
            t1.start();
            t2.start();
        }
    }
}
